#!/bin/bash
#
# RJP https://puolanka.info/goto/youtube-lataaja/
# Remade from https://www.antixforum.com/forums/topic/simple-youtube-download-script/
# Use the latest yt-dlp https://github.com/yt-dlp/yt-dlp
#
        
TEXTDOMAINDIR=/usr/share/locale
TEXTDOMAIN=youtube-downloader2

TUBE="$(yad --title=$"Youtube Video Downloader" --center --width=500 --height=100 --text-align=center --text=$"PUT VIDEO´S ADDRESS INTO BOX" --entry --entry-label=$"ADRESS" --entry-text="")"
if [ $? = 0 ];
then
yad --title=$"Youtube Video Downloader" --center --width=500 --height=100 --text-align=center --text="ADDRESS IS: $TUBE"
xterm -e /bin/sh -c "yt-dlp --extractor-args "youtube:player-client=default,-tv_simply" -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' -S 'height:720' -o '%(title)s.%(ext)s' $TUBE" && \
sleep 1
yad --width=200 --center --buttons-layout=center --borders=5 --text-align=center --title=$"READY" --text=$"Video downloaded" --button=OK:1 --center
else exit 0
fi
